package adc.app.ui.wicket.table;

import org.apache.wicket.MarkupContainer;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;

import adc.app.ui.wicket.LabeledLinkPanel;

public abstract class AbstractLinkColumn<T> extends AbstractColumn<T> {

	private static final long serialVersionUID = 1L;
	
	public AbstractLinkColumn(IModel<String> displayModel, String sortProperty) {
		super(displayModel, sortProperty);
	}

	public AbstractLinkColumn(IModel<String> displayModel) {
		super(displayModel);
	}


	@Override
	public final void populateItem(Item<ICellPopulator<T>> cellItem, String componentId, IModel<T> rowModel) {
		MarkupContainer link = createLink(componentId, rowModel);
		cellItem.add(link);
	}

	protected abstract LabeledLinkPanel createLink(String idLink, IModel<T> model);
	
	protected static class AbstractLinkPanel extends Panel {

		private static final long serialVersionUID = 1L;
		
		public AbstractLinkPanel(String id) {
			super(id);
		}
	}

}
